import request from '@/utils/request'
import { encryptedData } from '@/utils/encrypt'
import { loginRSA, tokenName } from '@/config'

export async function login(data) {
  /* if (loginRSA) {
    data = await encryptedData(data)
  } */
  return request({
    url: '/SysUser/login',
    method: 'post',
    data,
  })
}

export function getUserInfo(accessToken) {
  return request({
    url: '/userInfo',
    method: 'post',
    data: {
      [tokenName]: accessToken,
    },
  })
}

export function logout() {
  return request({
    url: '/logout',
    method: 'post',
  })
}

export function register() {
  return request({
    url: '/register',
    method: 'post',
  })
}

//后台获取打卡记录
export function GetClockRecord(params) {
  return request({
    url: '/SysUser/GetClockRecord',
    method: 'get',
    params,
  })
}

//后台删除打卡记录
export function DelClockRecord(params) {
  return request({
    url: '/SysUser/DelClockRecord',
    method: 'get',
    params,
  })
}

//后台查询学校接口
export function GetSchoolList(params) {
  return request({
    url: '/SysConfig/GetSchoolList',
    method: 'get',
    params,
  })
}

//后台编辑学校
export function SetSchool(data) {
  return request({
    url: '/SysConfig/SetSchool',
    method: 'post',
    data,
  })
}
//后台添加学校
export function AddSchool(data) {
  return request({
    url: '/SysConfig/AddSchool',
    method: 'post',
    data,
  })
}
//后台删除学校
export function DelSchool(params) {
  return request({
    url: '/SysConfig/DelSchool',
    method: 'get',
    params,
  })
}
